import json
import os
import datetime
import time


#t=['internal_isop_incident','bsa_traffic','bsa_org','bsa_normal']
t=['bsa_traffic']
def main(date_list):
    for part in t:
        print part
        for da in date_list:
            cmd1 = "curl -XDELETE http://esph:19399/%s-%s-0/_alias/%s-%s?pretty " %(part,da,part,da)
            cmd2 = "curl -XDELETE http://esph:19399/%s-%s-0/_alias/%s?pretty" %(part,da,part)
            cmd3 = "curl -XDELETE http://esph:19399/%s-%s-0?pretty" %(part,da)
            print cmd1
            print cmd2
            print cmd3
            os.system(cmd1)
            os.system(cmd2)
            os.system(cmd3)

def get_date(a):

    ret = []
    a1 = int(time.time())
    for i in range(0,a):
        b = a1 - i*86400
        t2 = time.strftime('%Y%m%d',time.localtime(b))
        ret.append(t2)
    return ret;

def get_two(start,end):
    ret = []
    a1 = int(time.time())
    for i in range(0,1000):
        b = start + i*86400
        if b < end:
            t2 = time.strftime('%Y%m%d',time.localtime(b))
            ret.append(t2)
    return ret;


if __name__ == '__main__':
    #date_list = get_date(60) 根据日期来找出对应之间的天数
    start='20220126'
    end='20220228'
    s1 = int(time.mktime(time.strptime(start, '%Y%m%d')))
    e1 = int(time.mktime(time.strptime(end, '%Y%m%d')))

    #date_list = get_two(cur-90*86400,cur-60*86400)
    date_list = get_two(s1,e1)
    print date_list
    #main(date_list)
    # 使用datetime类获取当前日期和时间
    datetime.now().date().strftime('%Y-%m-%d') ## '2019-02-26'
    datetime.now().time().strftime('%H:%M:%S') ## '15:48:43'
    """
    str_time = '2019-02-26 13:04:41'
    time.mktime(time.strptime(str_time, '%Y-%m-%d %H:%M:%S')) # 1551157481.0
    # 获取当前
    time.strftime('%Y-%m-%d')
    time.strftime('%H:%M:%S')
    """